<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .rating {
      display: flex;
      align-items: center;
      justify-content: center;
      /*从右往左排列，关键性代码*/
      flex-direction: row-reverse;
    }
    .rating-star {
      position: relative;
      margin: 0 2px;
      font-size: 42px;
      color: #ddd;
    }
    .rating-star::before {
      /* \2605是 Unicode 转义序列 表示实心五角星 ★ */
      content: "\2605";
      left: 0px;
      position: absolute;
    }
    /*鼠标滑动到星上时，星后面对应的星都变红*/
    .rating-star:hover::before,
    .rating-star:hover ~ .rating-star::before {
      color: red;
    }
  </style>
  <body>
    <div class="rating">
      <span class="rating-star">☆</span>
      <span class="rating-star">☆</span>
      <span class="rating-star">☆</span>
      <span class="rating-star">☆</span>
      <span class="rating-star">☆</span>
    </div>
  </body>
</html>